import { createRouter, createWebHistory } from 'vue-router'
// import HomeView from '../views/HomeView.vue'
import Index from '../components/pages/Index'
import Contents from '@/components/pages/Contents'
import Lables from '@/components/pages/Lables'
import Login from '@/components/pages/Login'
import Regist from '@/components/pages/Regist'
import Admin from '@/components/admin/Admin'
import NewEassy from  '@/components/admin/NewEssay'
import Tags from '@/components/admin/Tags'
import Settings from  '@/components/admin/Settings'
import Draft from '@/components/admin/Draft'
import DraftContent from '@/components/admin/DraftContent'
import Updated from '@/components/admin/Update'
import Comments from '@/components/admin/Comments'
// const routes = [

// ]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes:[
    {
      path: '/',
      name: 'Index',
      component: Index
    },
    {
      path: '/contents',
      name: 'Contents',
      component: Contents
    },
    {
      path: '/lables',
      name: 'Lables',
      component: Lables
    },
    {
      path: '/login',
      name: 'Login',
      component:Login
    },
    {
      path: '/regist',
      name: 'Regist',
      component: Regist
    },
    {
      path: '/admin',
      name: 'admin',
      meta: {
        requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
      },
      component: Admin,
      children: [
        {
          path: 'newEssay',
          name: 'newEssay',
          meta: {
            requireAuth: true,  
          },
          component: NewEassy
        },
        {
          path: 'tags',
          name: 'tags',
          meta: {
            requireAuth: true, 
          },
          component: Tags
        },
        {
          path: 'settings',
          name: 'settings',
          meta: {
            requireAuth: true,  
          },
          component: Settings
        },
        {
          path: 'draft',
          name: 'draft',
          meta: {
            requireAuth: true, 
          },
          component: Draft
        },
        {
          path: 'content',
          name: 'content',
          meta: {
            requireAuth: true,  
          },
          component: DraftContent
        },
        {
          path: 'update',
          name: 'update',
          meta: {
            requireAuth: true,  
          },
          component: Updated
        },
        {
          path: 'comments',
          name: 'comments',
          meta: {
            requireAuth: true,  
          },
          component:Comments
        }
      ]
    },
    {
      path: "/404",
      name: "notFound",
      component:'@/components/pages/NotFound'
    },
    {
      path: "/:pathMatch(.*)",
      redirect: "/404"
    }
  ]
  
})

export default router
